// 订单列表
import request from '../utils/request.js'
// 获取用户订单列表
const getUserOrder = data =>{
  return request({
    url: '/api/auth/userOrder/list',
    method: 'POST',
    data
  })
}
//获取订单详情
const getUserOrderDetail = orderid =>{
  return request({
    url: '/api/auth/userOrder/detail/'+orderid,
    method: 'POST'
  })
}
//申请退款 
const refund = data => {
  return request({
    url: '/api/auth/userOrder/refund/',
    method: 'POST',
    data
  })
}


//申请单个或多个参赛者退款【4/13】
const joinRefund = data => {
  return request({
    url: '/api/auth/userOrder/joinRefund/',
    method: 'POST',
    data
  })
}
//取消订单
const cancel = orderId => {
  return request({
    url: `/api/auth/userOrder/cancel/${orderId}`,
    method: 'POST'
  })
}

//查看是否有未支付的赛事订单
const checkUnPay = matchId => {
  return request({
    url: `/api/auth/userOrder/checkUnPay/${matchId}`,
    method: 'POST'
  })
}



//计算订单价格（第一步）
const setCalculate = data =>{
  return request({
    url: '/api/auth/order/calculate',
    method: 'POST',
    data
  })
}
//创建订单 （第二步）
const createOrder = data =>{
  return request({
    url: '/api/auth/order/create',
    method: 'POST',
    data
  })
}
//微信支付（第三步） 
const orderpay = orderSn =>{
  return request({
    url: '/api/auth/order/pay/'+orderSn,
    method: 'POST'
  })
}
//主动查询订单支付状态（第四步）
const queryOrder = orderSn =>{
  return request({
    url: '/api/auth/order/query/'+orderSn,
    method: 'POST'
  })
}
module.exports = {
  getUserOrder,
  getUserOrderDetail,
  setCalculate,
  createOrder,
  orderpay,
  queryOrder,
  refund,
  joinRefund,
  cancel,
  checkUnPay
}